<?php
session_start();

define ('SR_ADMIN_PASSWORD', 'Silesia123!');

class Auth {
	public static function isAdmin() {
		if (isset($_SESSION['admin']) && isset($_SESSION['admin_pass']) && 
			$_SESSION['admin'] == 1 && $_SESSION['admin_pass'] == SR_ADMIN_PASSWORD) return true;
		else return false;
		
	}
	
	public static function logout() {
		unset ($_SESSION['admin']); unset ($_SESSION['admin_pass']);
		session_destroy();
		session_start();
		session_regenerate_id();
	}
	
	public static function login($password) {
		if ($password != SR_ADMIN_PASSWORD) return false;
		session_regenerate_id();
		$_SESSION['admin'] = 1;
		$_SESSION['admin_pass'] = $password;
		return true;
	}

}

